#coding=utf-8
import csv
from django.core.management import BaseCommand
from interview.models import Candidate

class Command(BaseCommand):
    help = "导入CSV"

    def add_arguments(self, parser):
        parser.add_argument("--path", type=str)

    def handle(self, *args, **options):
        path = options['path']
        with open(path, 'r',encoding='utf-8') as f:
            reader = csv.reader(f)
            for row in reader:
                candidate = Candidate.objects.create(
                    username = row[0],
                    city = row[1],
                    phone = row[2],
                    degree = row[3],
                    paper_score= row[4]
                )
                print(candidate)

